package com.example.musicplatform.service.impl;

import com.example.musicplatform.common.Constants;
import com.example.musicplatform.entity.User;
import com.example.musicplatform.pojo.ResponseData;
import com.example.musicplatform.service.LoginService;
import com.example.musicplatform.util.MD5Utils;
import com.example.musicplatform.util.ResponseDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @Author: caowj1217
 * @Date: 2021/7/23上午11:27
 * @Description:
 */
@Service
public class LoginServiceImpl implements LoginService {


//    @Autowired
//    UserRepository userRepository;
    @Override
    public ResponseData findUserByUserNameAndPassWord(User user) {
//        if (StringUtils.isEmpty(user.getUserName())|| StringUtils.isEmpty(user.getPassWord())){
//            return ResponseDataUtil.buildError(Constants.PARAMS_INVALID_CODE,Constants.PARAM);
//        }
//        try{
//            String md5Password = MD5Utils.MD5Encode(user.getPassWord(),Constants.DEFAULT_CHARSET);
//                User selectUser = userRepository.findUserByUserNameAndPassWord(user.getUserName(),md5Password);
//            if(selectUser == null){
//                return ResponseDataUtil.buildError(Constants.USERNAME_OR_PASSWORD_ERROR_CODE,Constants.USERNAME_OR_PASSWORD_ERROR_MSG,user);
//            }
//            if(!md5Password.equals(selectUser.getPassWord())){
//                return ResponseDataUtil.buildError(Constants.USERNAME_OR_PASSWORD_ERROR_CODE, Constants.USERNAME_OR_PASSWORD_ERROR_MSG,user);
//            }
//            return ResponseDataUtil.buildSuccess(selectUser);
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }
        return ResponseDataUtil.buildSuccess();
    }
}
